Skip to content

feat(broker): a training keeps its lock while berthd is away - #317

Merged
T-Crypt merged 1 commit into
nextfrom
T-Crypt/train-fail-closed
Nov 13, 2026
Merged

T-Crypt merged 1 commit into
nextfrom
T-Crypt/train-fail-closed

Conversation

@T-Crypt

@T-Crypt T-Crypt commented Nov 13, 2026

Copy link
Copy Markdown
Owner

What

A berth train run keeps its lock while berthd is away.

  • With berthd down, berth run refuses to start an engine while a training runs on the node. Before, it started
    the engine without a lease, beside the training.
  • A berthd that starts while a training runs refuses every other request until the training re-attaches, with no
    time limit. Other engines still get the 15 second re-attach window.
  • The lock ends when the training's process ends.

Why

#314 made a training lock its cards while berthd runs. A berthd crash, restart or upgrade opened a gap: an engine
started in that time ran unprotected beside the training, and a training that re-attached after the window found
other work granted on its card.

How

  • runs.Record gains Training. The runner sets it when a training records that it lost berthd.
  • runs.Training finds a live training record. The runner checks it before it starts an engine unprotected.
  • dueToReattach drops the window for a training record. lockedBy names a training lease or a training record
    not yet re-attached, and refuse uses it, so other requests are refused at once instead of held.

Proof

  • .claude/skills/berth-verify/proof.sh: full proof OK.
  • TestTrainingLocksTheCardUntilItReattaches fails with the old window rule and passes with the change.
  • TestTrainingRecordLocksOnlyWhileItsProcessLives, TestTrainingIsALiveTrainingRecord and
    TestRunRefusesWithoutADaemonWhileATrainingRuns (a real berth run with no berthd and a live training record:
    refused, command never started) cover the rest.

A berth train run records itself as a training when it loses berthd. With
berthd down, berth run refuses to start an engine while a live training
record exists, instead of starting it without a lease. A berthd that starts
while a training runs treats its record as the lock: it refuses every other
request until the training re-attaches, with no time limit, where other
engines get the 15 second re-attach window.
@T-Crypt
T-Crypt merged commit 6e2dc74 into next Nov 13, 2026
4 checks passed
@T-Crypt
T-Crypt deleted the T-Crypt/train-fail-closed branch November 13, 2026 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant